package part18;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

/**
 * @author wcj
 * @Date 2021/6/3 17:08
 * @Version 1.0
 */
public class Part187 {

    /**
     * IO流的经典使用方式之一：缓冲输入文件
     *
     * @param filename
     * @return
     * @throws IOException
     */
    public static String read(String filename) throws IOException {
        BufferedReader in = new BufferedReader(new FileReader(filename));
        String s;
        StringBuilder sb = new StringBuilder();
        while ((s = in.readLine()) != null) {
            sb.append(s + "\n");
        }
        in.close();
        return sb.toString();
    }

    public static void main(String[] args) throws IOException {
        System.out.println(read("./src/part18/Part187.java"));
    }
}
